package config

import (
	"github.com/pelletier/go-toml"
	"log"
)

type Config struct {
	TdDsn         string    `toml:"td_dsn"`
	BatchSize     int       `toml:"batch_size"`
	GoroutineSize int       `toml:"goroutine_size"`
	LogMetas      []LogMeta `toml:"log_metas"`
}

type LogMeta struct {
	Enable      bool   `toml:"enable"`
	LogFilePath string `toml:"log_file_path"`
	AppName     string `toml:"app_name"`
	NodeId      string `toml:"node_id"`
}

var Conf Config

func init() {
	// 读取 TOML 配置文件
	configFile := "config.toml"
	configTree, err := toml.LoadFile(configFile)
	if err != nil {
		log.Fatalf("Error loading TOML file: %v", err)
	}
	// 将 TOML 配置映射到结构体
	err = configTree.Unmarshal(&Conf)
	if err != nil {
		log.Fatalf("Error unmarshaling TOML file: %v", err)
	}
}
